package com.lagou.order.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.common.pojo.OrderVo;
import com.lagou.common.pojo.Orders;
import com.lagou.order.mapper.OrderMapper;
import com.lagou.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongProject: lagou-parent
 * @author: 胡恺恺
 * @createTime: 2021/1/29  13:56
 * @Description:
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    /**
     * 分页多条件查询
     * @param orderVo
     * @return
     */
    @Override
    public PageInfo<Orders> queryByPage(OrderVo orderVo) {
        PageHelper.startPage(orderVo.getCurrentPage(),orderVo.getPageSize());
        List<Orders> ordersList = orderMapper.queryByPage(orderVo);

        PageInfo<Orders> pageInfo = new PageInfo<>(ordersList);
        return pageInfo;
    }

    /**
     * 根据订单id查询订单
     * @param id
     * @return
     */
    @Override
    public Orders queryById(Integer id) {
        return orderMapper.selectById(id);
    }

    /**
     * 根据订单id查询订单商品中间表中关联的商品id
     */
    @Override
    public List<Integer> findGoodsIdByOrderId(Integer id) {
        return orderMapper.findGoodsIdByOrderId(id);
    }


}
